package com.freemypay.test.并发.后台线程;

import java.util.concurrent.TimeUnit;

/**
 * 后台线程不执行try catch 后面的finally
 * 注：因为main()退出，jvm会关闭所有的后台进程。
 * @author yesixian
 *
 */
public class DaemonsDontRunFinally {
	public static void main(String[] args) {
		Thread t = new Thread(new ADaemon());
		t.setDaemon(true);
		t.start();
	}
}

class ADaemon implements Runnable {
	@Override
	public void run() {
		try {
			System.out.println("Starting ADaemo");
			TimeUnit.SECONDS.sleep(1);
		} catch (InterruptedException e) {
			System.out.println("exiting via InterruptedException");
		}finally {
			System.out.println("this should always run?");
		}
	}
}
